package com.woogie.app;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;

import com.woogie.serv.async.SendMessage;

@SuppressLint("NewApi") public class WoogieActivity extends Activity implements OnClickListener{
	
	private int state = 0;
    private static int fakeNumber = 0;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chats);

        ActionBar bar = getActionBar();
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);

        View view = View.inflate(getApplicationContext(), R.layout.top_bar,
                null);
        bar.setCustomView(view);

        (findViewById(R.id.contacts)).setOnClickListener(this);
        (findViewById(R.id.message)).setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu, menu);
        return true;
    }
    
    @Override
    public void onBackPressed() {
    	switch(state)
    	{
    	case 0:
    		break;
    	}
    }
    
    @Override
    public void finish() {
    	new AlertDialog.Builder(this)
        .setIcon(android.R.drawable.ic_dialog_alert)
        .setTitle("Closing Activity")
        .setMessage("Are you sure you want to close this activity?")
        .setPositiveButton("Yes", new DialogInterface.OnClickListener()
	    {
	        @Override
	        public void onClick(DialogInterface dialog, int which) {
	            finish();    
	        }
	
	    })
	    .setNegativeButton("No", null)
	    .show();
    }
    
    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
    	String itemS = "";
    	switch(item.getItemId()){
    	case R.id.itemid_0:
    		itemS = "New Contact";
    		setContentView(R.layout.new_contacts);
    		break;
    	case R.id.itemid_1:
    		itemS = "Chats";
    		setContentView(R.layout.chats);
    		break;
    	case R.id.itemid_2:
    		itemS = "TinkPad";
    		setContentView(R.layout.tinkpad);
    		break;
    	case R.id.itemid_3:
    		itemS = "Points";
    		setContentView(R.layout.points);
    		break;
    	case R.id.itemid_5:
    		itemS = "Settings";
    		setContentView(R.layout.settings);
    		break;
    	}

    	return super.onMenuItemSelected(featureId, item);
    }

	@Override
	public void onClick(View v) {
		String itemS = "";
		switch (v.getId())
		{
		case R.id.contacts:
			itemS = "Contacts";
    		setContentView(R.layout.contacts);
    		break;
		case R.id.message:
			itemS = "New Message";
    		setContentView(R.layout.new_message);
    		break;
		}
	}

    public void sendFakeSms(View v)
    {
        new SendMessage("+15149670418", "Fake Message #: " + fakeNumber++).send();
    }
}
